<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.prime.com.tr/ui"
	template="../templates/template.xhtml">

	<ui:define name="content">
		<h:form id="userform">
			<p:dataTable id="users" var="user"
				value="#{userManagedBean.searchUsersResults}"
				selection="#{userManagedBean.selectedUser}" selectionMode="single"
				paginator="true" rows="10" style="width: 700">

				<p:ajax event="rowSelect" update=":userform:display"
					oncomplete="userDialog.show()" />

				<p:column sortBy="#{user.id}" filterBy="#{user.id}">
					<f:facet name="header">
						<h:outputText value="Id" />
					</f:facet>
					<h:outputText value="#{user.id}" />
				</p:column>
				<p:column sortBy="#{user.name}" filterBy="#{user.name}">
					<f:facet name="header">
						<h:outputText value="Name" />
					</f:facet>
					<h:outputText value="#{user.name}" />
				</p:column>
				<p:column parser="date" sortBy="#{user.expireDate}"
					filterBy="#{user.expireDate}">
					<f:facet name="header">
						<h:outputText value="Expire Date" />
					</f:facet>
					<h:outputText value="#{user.expireDate}">
						<f:convertDateTime pattern="yyyy-MM-dd" />
					</h:outputText>
				</p:column>
				<f:facet name="footer">
					<p:commandButton value="Update" image="ui-icon ui-icon-search"
						update="users" actionListener="#{userManagedBean.searchUser}" />

				</f:facet>

			</p:dataTable>
			<p:dialog header="Users Details" widgetVar="userDialog"
				resizable="false" width="700" modal="true">
				<h:panelGrid columns="4" cellpadding="4" id="display" border="0">

					<h:outputText value="Name:" />
					<h:inputText value="#{userManagedBean.selectedUser.name}"
						readonly="true"></h:inputText>

					<h:outputText value="Description:" />
					<h:inputText value="#{userManagedBean.selectedUser.description}"
						readonly="true"></h:inputText>

					<h:outputText value="Language:" />
					<h:inputText value="#{userManagedBean.selectedUser.languageID}"
						readonly="true"></h:inputText>

					<h:outputText value="Expire Date:" />
					<h:inputText value="#{userManagedBean.selectedUser.expireDate}"
						readonly="true">
						<f:convertDateTime pattern="yyyy.MM.dd 'at' HH:mm:ss z"
							timeZone="Europe/Berlin" />
					</h:inputText>

					<h:outputText value="Pwd Changed:" />
					<h:inputText value="#{userManagedBean.selectedUser.lastPWDChange}"
						readonly="true">
						<f:convertDateTime pattern="yyyy.MM.dd 'at' HH:mm:ss z"
							timeZone="Europe/Berlin" />
					</h:inputText>
					<h:outputText value="Failed Login:" />
					<h:inputText
						value="#{userManagedBean.selectedUser.failedLoginCount}"
						readonly="true"></h:inputText>

					<h:outputText value="Locked:" />
					<h:selectBooleanCheckbox
						value="#{userManagedBean.selectedUser.locked}" />
					<h:outputText value="Valid:" />
					<h:selectBooleanCheckbox
						value="#{userManagedBean.selectedUser.valid}" />
				</h:panelGrid>
			</p:dialog>
		</h:form>
	</ui:define>

</ui:composition>